package com.starbaba.module.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.base.common.database.BaseDao;
import com.starbaba.core.web.page.PageResponse;
import com.starbaba.model.dictionary.Constant;
import com.starbaba.module.model.LoanContentActivity;
import com.starbaba.module.service.ILoanContentActivityService;

@Component
@SuppressWarnings({"rawtypes","deprecation"})
public class LoanContentActivityServiceImpl implements ILoanContentActivityService{
	
    private static BaseDao dao = new BaseDao(Constant.POOL_LIFE);

	@Override
	public List getActivityList(int iDisplayStart, int iDisplayLength, PageResponse pageResponse, Map<String, Object> paramsMap) {
		
	    String name = (String) paramsMap.get("name");
		StringBuffer sf = new StringBuffer();
		StringBuffer tt = new StringBuffer();
		sf.append("select * From loan_content_activity as c where 1=1 ");

		if (name != null && name != "") {
			tt.append(" and  c.name like '%" + name + "%'");
		}
		
		sf.append(tt.toString());
		sf.append(" order by c.ctime desc LIMIT " + iDisplayStart + "," + iDisplayLength);
		List<LoanContentActivity> list = null;
		try {
			list = dao.list(sf.toString(), LoanContentActivity.class, new Object[] {});
			String countHql = "select count(*) loan_content_activity as c where 1=1 " + tt.toString();
			int count = dao.getInt(countHql, new Object[] {});

			pageResponse.setITotalRecords(count);
			pageResponse.setITotalDisplayRecords(count);
		} catch (Exception e) {

		}
		return list;
	}
}
